/**
 * event
 * seearch 点击搜索事件
 * realSearch 实时搜索
 * clearSearch 清除搜索结果
 */
const app = getApp(),
  {
    $resHost
  } = app.globalData;
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    placeholder: {
      type: String,
      value: '搜索'
    },
    show: {
      type: Boolean,
      value: false
    },
    living: {
      //实时搜索
      type: Boolean,
      value: false
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    home_list_filter: `${$resHost}/img/miniprogram/home/home_list_filter.png`,
    value: ''
  },
  /**
   * 组件的方法列表
   */
  methods: {
    clearInput(e) {
      this.setData({
        value: ""
      });
      this.triggerEvent('clearSearch', e.detail);
    },
    inputTyping(e) {
      this.setData({
        value: e.detail.value
      });
      // this.triggerEvent('realSearch', { value: this.data.value });
      if (this.data.living) {
        this.triggerEvent('search', {
          value: this.data.value
        });
      }
    },
    bindconfirm(e) {
      this.triggerEvent('search', {
        value: this.data.value
      });
    },
    bindfilter() {
      this.triggerEvent('filter');
    }
  }
});